package com.linwen.tips.commonmethod;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;

public class AfterOptimize {

    public static void processNames(List<String> names, Function<String, String> nameProcessor, String processType) {
        System.out.println(processType + " Names:");
        for (String name : names) {
            String processedName = nameProcessor.apply(name);
            System.out.println(processedName);
        }
    }

    public static void main(String[] args) {
        List<String> names = Arrays.asList("Tom", "Bob", "Alice", "David","Jack");

        processNames(names, s -> s.toUpperCase(Locale.ROOT), "Uppercase");
        processNames(names, String::toLowerCase, "Lowercase");
    }

}
